﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DOTNETGROUP.Data;
using DOTNETGROUP.Entities;

public partial class Chi_Tiet_Video : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            hienThiVideo();
        }
    }

    /// <summary>
    /// Hiển thị Video
    /// </summary>
    void hienThiVideo()
    {
        string strHTML = "";

        Video ent_Video = DataRepository.VideoProvider.GetById(Convert.ToInt32(Request.Params["Id"]));

        if (ent_Video != null)
        {
            String c = "//www.youtube.com/embed/";

            strHTML += "<iframe width=\"100%\" height=\"390px\" src=\"" + c + ent_Video.MaCode + "\" frameborder=\"0\" allowfullscreen></iframe>";
            hienthidiengiai.Text = ent_Video.TomTat;
            disPlayVideoRequest.Text = strHTML;
            lblLoaiVideo.Text = GetLoaiVideo(Convert.ToInt32(ent_Video.IdLoaiVideo));
            litTieuDe.Text = ent_Video.TieuDe;
            litDienGiai.Text = String.Format("<meta content='{0}' name='description' />", ent_Video.TomTat);
            linkloaivideo.NavigateUrl = String.Format("~/VideoCatalog/{0}_{1}", GetTieuDe(GetLoaiVideo(Convert.ToInt32(ent_Video.IdLoaiVideo))), ent_Video.IdLoaiVideo) + ".aspx";
        }
    }

    /// <summary>
    /// Lấy Tiêu đề để Convert sang không dấu
    /// </summary>
    /// <param name="Char"></param>
    /// <returns></returns>
    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }

    /// <summary>
    /// Lấy Tên Loại Video
    /// </summary>
    /// <param name="idLoaiVideo"></param>
    /// <returns></returns>
    public string GetLoaiVideo(object idLoaiVideo)
    {
        int id = Convert.ToInt32(idLoaiVideo.ToString());
        using (LoaiVideo ent_LoaiVideo = DataRepository.LoaiVideoProvider.GetById(id))
        {
            return ent_LoaiVideo.TenLoaiVideo;
        }
    }
}